package cn.edu.jmu.oelp.mapper;

import cn.edu.jmu.oelp.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author huanghongbe
 */
@Repository
public interface UserMapper {


    //@Select("select * from user where account=#{account} and password=#{password}")
    public User userLogin(User user);

    /**
     * 用于添加用户
     * @param user
     * @return 成功返回True
     */
    //@Insert("insert into user(account,password,username,src) values(#{account},#{password},#{username},#{src})")
    public boolean addUser(User user);

    /**
     * 用于删除用户
     * @param id
     * @return
     */
    //@Delete("delete from user where id=#{id}")
    public boolean delUser(int id);

    /**
     * 用于修改用户
     * @param user
     * @return
     */
    //@Update("update user set account=#{account},password=#{account},username=#{account},src=#{account} where id=#{id}")
    public boolean updateUser(User user);
    /**
     * 用于通过用户名查询用户，通过该方法可查询同名用户
     * @param username
     * @return User对象
     */
    //@Select("select * from user where username=#{username}")
    public List<User> selUserByUserName(@Param("username") String username);

    /**
     * 用于通过账户名查询用户-----账户名(手机号或者邮箱) 通过该方法查找的用户唯一
     * @param account
     * @return User对象
     */
    //@Select("select * from user where account=#{account}")
    public User selUserByAccount(@Param("account") String account);

    /**
     * 用于通过id查询用户，通过该方法查找的用户唯一
     * @param id
     * @return User对象
     */
    //@Select("select * from user where id=#{id}")
    public User selUserById(int id);
}
